<script language="JavaScript" type="text/javascript">

function addUploadFiles(){
    var i =  document.getElementById("uploadnum").value;
    i =i*1;
    i=i+1;
 	var  newRowIndex = i + 1;
 document.getElementById("uploadnum").value = i;

   var x=document.getElementById('imagesTabAdd').insertRow(newRowIndex);

   var y=x.insertCell(0);
   var z=x.insertCell(1);
   var a=x.insertCell(2);

   y.innerHTML=i;
   z.innerHTML="<input type='file' name='file"+i+"' id='file"+i+"' /></td>";
   
}
</script>
<form action="" method="post" class="validate" enctype="multipart/form-data">
    <div id="ermsg"><?php echo $uploadDiv;?></div>
  <table width="100%" border="0" cellpadding="4" cellspacing="0" id="imagesTabAdd">

     <tr>
      <th>Upload Directory</th>
      <th align="left" colspan="2"><input type="text" name="dirname" class="reqd" /></th>

    </tr><tr>
      <th>&nbsp;</th>
      <th align="left">File</th>
      <th>Description</th>
    </tr>
    <?php for($i=1;$i<=4;$i++){ ?>
    <tr id="id_<?php echo $i; ?>">
      <td><?php echo $i; ?></td>
      <td><input type="file" name="file<?php echo $i; ?>" id="file<?php echo $i; ?>" /></td>
      
    </tr>

    <?php } ?>
    <input type="hidden" value="4" name="uploadnum" id="uploadnum" />
    <input type="hidden" value="uploads" name="MM_insert"  />
<div id="moreuploads"></div>
    </table>
    <input type="submit" value="Upload" name="submit" />
<a href="#" onclick="addUploadFiles();">Add more image space</a>
</form>
<div class="data">
    <?php  // $utility->listFileInDirectory("../../gscs"); ?>

</div>